package com.cwk.yygh.hosp.controller.api;

import com.cwk.yygh.common.result.Result;
import com.cwk.yygh.hosp.service.DepartmentService;
import com.cwk.yygh.hosp.service.HospitalService;
import com.cwk.yygh.hosp.service.HospitalSetService;
import com.cwk.yygh.hosp.service.ScheduleService;
import com.cwk.yygh.model.hosp.Hospital;
import com.cwk.yygh.vo.hosp.HospitalQueryVo;
import com.cwk.yygh.vo.hosp.ScheduleOrderVo;
import com.cwk.yygh.vo.order.SignInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/hosp/hospital")
public class HospApiController {
    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private ScheduleService scheduleService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private HospitalSetService hospitalSetService;
    @GetMapping("findHospList/{page}/{limit}")
    public Result findHospList(@PathVariable Integer page,
                               @PathVariable Integer limit,
                               HospitalQueryVo hospitalQueryVo){
        Page<Hospital> list =hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(list);
    }
    @GetMapping("findByHosName/{hosname}")
    public Result findByHosName(@PathVariable String hosname){
        List<Hospital> list = hospitalService.findByHosName(hosname);
        return Result.ok(list);
    }
    @GetMapping("department/{hoscode}")
    public Result findDepartment(@PathVariable String hoscode){
        return Result.ok(departmentService.findDepartmentByHoscode(hoscode));
    }
    @GetMapping("findHospDetail/{hoscode}")
    public Result findHospDetail(@PathVariable String hoscode){
        Map<String, Object> map = hospitalService.findHospDetail(hoscode);
        return Result.ok(map);
    }
    //获取可预约的排班数据
    @GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getBookintSchedule(@PathVariable Integer page,@PathVariable Integer limit,@PathVariable String hoscode,@PathVariable String depcode){
        return Result.ok(scheduleService.getBookingScheduleRule(page,limit,hoscode,depcode));
    }
    //获取排班数据
    @GetMapping("auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public Result getBookintSchedule(@PathVariable String hoscode,@PathVariable String depcode,@PathVariable String workDate){
        return Result.ok(scheduleService.getDetailSchedule(hoscode, depcode, workDate));
    }
    //获取排班id获取排班数据
    @GetMapping("getSchedule/{scheduleId}")
    public Result getSchedule(@PathVariable String scheduleId) {
        return Result.ok(scheduleService.getById(scheduleId));
    }
    //根据排班id获取预约下单数据
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@PathVariable("scheduleId") String scheduleId) {
        return scheduleService.getScheduleOrderVo(scheduleId);
    }
    //根据排班id获取医院签名数据
    @GetMapping("inner/getSignInfoVo/{hoscode}")
    public SignInfoVo getSignInfoVo(@PathVariable("hoscode") String hoscode) {
        return hospitalSetService.getSignInfoVo(hoscode);
    }
}
